﻿@model BrnMall.Web.StoreAdmin.Models.OrderStatModel
           
@section header{
    <title>订单统计-报表统计</title>
    <link type="text/css" rel="stylesheet" href="/admin_store/css/site.css" />
    <!--[if lte IE 8]><script type="text/javascript" src="/admin_store/scripts/excanvas.js"></script><![endif]-->
    <script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.flot.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.flot.pie.js"></script>
    <script type="text/javascript" src="/components/my97datepicker/WdatePicker.js"></script>
    <script type="text/javascript">
     @{
         if (Model.StatItemList.Rows.Count > 0)
         {
             StringBuilder dataset = new StringBuilder();
             foreach (DataRow row in Model.StatItemList.Rows)
             {
                 string state = "";
                 OrderState orderState = (OrderState)TypeHelper.ObjectToInt(row["orderstate"]);
                 switch (orderState)
                 {
                     case OrderState.WaitPaying:
                         state = "等待付款";
                         break;
                     case OrderState.Confirming:
                         state = "待确认";
                         break;
                     case OrderState.Confirmed:
                         state = "已确认";
                         break;
                     case OrderState.PreProducting:
                         state = "备货中";
                         break;
                     case OrderState.Sended:
                         state = "已发货";
                         break;
                     case OrderState.Received:
                         state = "已收货";
                         break;
                     case OrderState.Cancelled:
                         state = "取消";
                         break;
                     case OrderState.Locked:
                         state = "锁定";
                         break;
                     default:
                         state = "未知状态";
                         break;
                 }
                 dataset.AppendFormat("{0}label:'{1}：{2}{3}',data:'{2}'{4},", "{", state, row["value"], Model.StatType == 0 ? "个" : "元", "}");
             }
             @:var dataset = [@Html.Raw(dataset.Remove(dataset.Length - 1, 1).ToString())];
             }
         else
         {
         @:var dataset = [];
             }
     }
    var options = {
        series: {
            pie: {
                show: true,
                label: {
                    show: true,
                    radius: 0.8,
                    background: {
                        opacity: 0.6,
                        color: '#000'
                    }
                }
            }
        }
    };

    $(function () {
        $("#StatType").find("option[value=@Model.StatType]").attr("selected", true)
        $.plot($("#flot-placeholder"), dataset, options);
    });
    </script>
}
@section body{
    @using (Html.BeginForm())
    {
    <h1 class="rightH1">
        微信小程序 &gt; 报表统计 &gt; <span class="rightH1-cur">订单统计</span> 
        <div class="right">
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </h1>
    <div class="dataListSearch">
        <table height="32">
            <tbody class="col3">
                <tr>
                    <td class="td1">
                        统计类型：
                        <select name="StatType" id="StatType">
                            <option value="0">订单数</option>
                            <option value="1">订单合计</option>  
                        </select>
                    </td>
                    <td class="td2">开始时间：@Html.TextBox("StartTime", Model.StartTime, new { height = "18", onfocus = "WdatePicker({el:'StartTime'})" })</td>
                    <td class="td3">结束时间：@Html.TextBox("EndTime", Model.EndTime, new { height = "18", onfocus = "WdatePicker({el:'EndTime'})" })</td>
                    <td><input id="Search" name="Search" type="image" class="searchBut submit" src="/admin_store/images/s.jpg" /></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="dataList">
        <br />
        <div id="flot-placeholder" style="width: 600px; height: 400px; margin-left: 100px;"></div>
        <br />
    </div>
    }
}
